# -*-coding:utf-8-*-

from bson.objectid import ObjectId
from daos.base import BaseRecord
from daos.base_async import BaseDao
import time, pymongo, json, logging, datetime
from utils.misc import generate_random_no
from tornado.gen import coroutine

Jobs_Document_Structure = {
    '_id': 'JOB_ID',
    'uid': 'USER_ID',
    'did': 'DEVICE_ID',

    'created_through': 'app|sys',
    'created_time': 123,  # 工单创建时间
    'done_time': 123,
    'done_by': 'who',

    'status': '...',

    'city': 'Zhuhai',
    'district': 'Xiangzhou',
}


class Job(BaseRecord):
    def __getattr__(self, item):
        return self.data[item]


class JobsDao(BaseDao):
    def __init__(self, db):
        super(JobsDao, self).__init__(db, 'jobs')

    def _get_record_object(self, data):
        return Job(data)

    @coroutine
    def get_job_list(self, uid, **query_arguments):
        pass

    @coroutine
    def create_job(self, uid, data):
        pass

    @coroutine
    def get_job(self, uid, oid, **kwargs):
        pass

    @coroutine
    def update_job(self, uid, oid, **kwargs):
        pass

    @coroutine
    def delete_job(self, uid, oid):
        pass
